﻿using System.ComponentModel;

namespace CI.Models
{
    public abstract class PropertyBindingBase : IPropertyBinding
    {
        protected PropertyBindingBase(INotifyPropertyChanged end1, string end1PropertyName, INotifyPropertyChanged end2,
                                      string end2PropertyName)
        {
            End1 = end1;
            End1PropertyName = end1PropertyName;
            End2 = end2;
            End2PropertyName = end2PropertyName;

            //TODO:Validate property names exist and types match?

            End1.PropertyChanged += End1_PropertyChanged;
            End2.PropertyChanged += End2_PropertyChanged;
        }

        public INotifyPropertyChanged End1 { get; private set; }
        public string End1PropertyName { get; private set; }
        public INotifyPropertyChanged End2 { get; private set; }
        public string End2PropertyName { get; private set; }

        protected abstract void End2_PropertyChanged(object sender, PropertyChangedEventArgs e);
        protected abstract void End1_PropertyChanged(object sender, PropertyChangedEventArgs e);
    }
}